package com.huixh.train.business.controller.admin;

import com.huixh.train.business.req.DailyTrainTicketQueryReq;
import com.huixh.train.business.req.DailyTrainTicketSaveReq;
import com.huixh.train.business.resp.DailyTrainTicketQueryResp;
import com.huixh.train.business.service.DailyTrainTicketService;
import com.huixh.train.common.resp.PageResult;
import com.huixh.train.common.resp.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author huixh
*/
@Validated
@Tag(name = "每日车票余票信息", description = "每日车票余票信息")
@RestController("adminDailyTrainTicketController")
@RequestMapping("/admin/dailyTrainTicket")
public class DailyTrainTicketController {
    @Resource
    private DailyTrainTicketService dailyTrainTicketService;

    @PostMapping("/save")
    public Result<?> save(@RequestBody @Valid DailyTrainTicketSaveReq dailyTrainTicketSaveReq) {
    dailyTrainTicketService.save(dailyTrainTicketSaveReq);
        return Result.success();
    }

    @PostMapping("/quest-list")
    public PageResult<List<DailyTrainTicketQueryResp>> query(@RequestBody @Valid DailyTrainTicketQueryReq dailyTrainTicketQueryReq) {
        return dailyTrainTicketService.queryList(dailyTrainTicketQueryReq);
    }

    @DeleteMapping("/delete/{id}")
    public Result<?> deleteById(@NotNull @PathVariable(name = "id") Long id) {
        dailyTrainTicketService.delete(id);
        return Result.success("删除成功");
    }

}